<?php
class Gnrt {
  public $model;
  public static function _() {
      $class = __CLASS__;
      $class = new $class();
      return $class;
  }
  
  public function __construct($options) {
    $this->model = camelcasify($options['model']);
  }
  
  public static function scaffold($options) {
    $generator = new Gnrt($options);
    $generator->render_model();
  }
  
  public function render_model() {
    $file_contents = "<?php\n" .
      "class " . $this->model . " extends Model {\n" .
        "\tpublic static function _() {\n" .
          "\t\t\$class = __CLASS__;\n" .
          "\t\t\$class = new \$class();\n" .
          "\t\treturn \$class;\n" .
        "\t}\n" .
      "}\n" .
    "?>";
    
    $handle = fopen(MODELS_PATH . $this->model . ".php", "w");
    fwrite($handle, $file_contents);
    fclose($handle);
  }
}
?>